using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Spec.Dto;
using JTZY.Model.Spec;
using JTZY.Service.Spec.ISpecService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2024-11-01
namespace JTZY.Admin.WebApi.Controllers.Spec
{
    /// <summary>
    /// 商品类型属性值表
    /// </summary>
    [Verify]
    [Route("spec/Corecmsgoodstypespecvalue")]
    public class CorecmsgoodstypespecvalueController : BaseController
    {
        /// <summary>
        /// 商品类型属性值表接口
        /// </summary>
        private readonly ICorecmsgoodstypespecvalueService _CorecmsgoodstypespecvalueService;

        public CorecmsgoodstypespecvalueController(ICorecmsgoodstypespecvalueService CorecmsgoodstypespecvalueService)
        {
            _CorecmsgoodstypespecvalueService = CorecmsgoodstypespecvalueService;
        }

        /// <summary>
        /// 查询商品类型属性值表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespecvalue:list")]
        public IActionResult QueryCorecmsgoodstypespecvalue([FromQuery] CorecmsgoodstypespecvalueQueryDto parm)
        {
            var response = _CorecmsgoodstypespecvalueService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询商品类型属性值表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespecvalue:query")]
        public IActionResult GetCorecmsgoodstypespecvalue(int Id)
        {
            var response = _CorecmsgoodstypespecvalueService.GetInfo(Id);
            
            var info = response.Adapt<CorecmsgoodstypespecvalueDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加商品类型属性值表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespecvalue:add")]
        [Log(Title = "商品类型属性值表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsgoodstypespecvalue([FromBody] CorecmsgoodstypespecvalueDto parm)
        {
            var modal = parm.Adapt<Corecmsgoodstypespecvalue>().ToCreate(HttpContext);

            var response = _CorecmsgoodstypespecvalueService.AddCorecmsgoodstypespecvalue(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新商品类型属性值表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespecvalue:edit")]
        [Log(Title = "商品类型属性值表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsgoodstypespecvalue([FromBody] CorecmsgoodstypespecvalueDto parm)
        {
            var modal = parm.Adapt<Corecmsgoodstypespecvalue>().ToUpdate(HttpContext);
            var response = _CorecmsgoodstypespecvalueService.UpdateCorecmsgoodstypespecvalue(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除商品类型属性值表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsgoodstypespecvalue:delete")]
        [Log(Title = "商品类型属性值表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsgoodstypespecvalue([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmsgoodstypespecvalueService.Delete(idArr));
        }

    }
}